﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace MVVMDemo
{
    class SongViewModel : INotifyPropertyChanged
    {
        public SongViewModel()
        {
            _song = new SongModel { ArtistName = "Unknown", SongTitle = "Unknown" };
        }


        private SongModel _song;

        public SongModel Song
        {
            get { return _song; }
            set { _song = value; }
        }

        
        public string ArtistName
        {
            get { return Song.ArtistName; }
            set 
            { 
                Song.ArtistName = value;
                RaisePropertyChanged("ArtistName");
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler!=null)
            {
                handler(this,new PropertyChangedEventArgs(propertyName));
            }
        }
    }
}
